package com.sg.service.biz.bff.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.sg.common.util.CommonFunctionHelper;
import com.sg.common.util.RedisUtil;
import com.sg.dto.biz.bff.req.*;
import com.sg.dto.biz.bff.res.*;
import com.sg.dto.integration.component.MemberMsgReceiveDto;
import com.sg.dto.integration.component.QuerySingleMessageRecipientListListComReqDto;
import com.sg.dto.integration.component.QuerySingleMessageRecipientListListComRespDto;
import com.sg.service.biz.bff.OfficialDocumentService;
import com.wicket.okrapp.integration.OfficialDocumentService;
import com.wicket.okrapp.integration.dto.*;
import com.sg.common.exception.Assert;
import com.wicket.okrcomponent.integration.MessageService;
import com.wicket.okrframework.integration.InductionRecordService;
import com.wicket.okrframework.integration.NullService;
import com.wicket.okrframework.integration.dto.*;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.stream.Collectors;

/**
 * @author ：
 * @version 1.0
 * @date ：
 */
@Service
public class OfficialDocumentServiceImpl implements OfficialDocumentService {

    @Resource
    private RedisUtil redisUtil;
    @Resource
    com.sg.service.biz.app.OfficialDocumentService fwAppOfficialDocumentClient;
    @Resource
    com.sg.service.biz.framework.InductionRecordService fwBaseInductionRecordClient;
    @Resource
    com.sg.service.biz.framework.NullService fwBaseNullClient;
    @Resource
    com.sg.service.biz.component.MessageService fwCompMessageClient;

    /**
     * B3查接收的公文列表[7942]
     * gen by moon at 12/15/2023, 2:48:59 PM
     */
    @Trace(operationName = "B3查接收的公文列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffQueryMyReceiveOfficialDocumentListRespDto queryMyReceiveOfficialDocumentList(BffQueryMyReceiveOfficialDocumentListReqDto reqDto) {


        QueryReceiveOfficialDocumentListRespDto queryReceiveOfficialDocumentListRespDto_1 = null;
//步骤0: D3查接收的公文列表 - queryReceiveOfficialDocumentList
        QueryReceiveOfficialDocumentListRespDto queryReceiveOfficialDocumentListRespDto = null;
        QueryReceiveOfficialDocumentListReqDto queryReceiveOfficialDocumentListReqDto = new QueryReceiveOfficialDocumentListReqDto();
        if (reqDto != null) {
            queryReceiveOfficialDocumentListReqDto.setEntityId(reqDto.getEntityId());//SimpleFieldAssign//sourceId:1314348_1
            queryReceiveOfficialDocumentListReqDto.setTableTypeCode(reqDto.getTableTypeCode());//SimpleFieldAssign//sourceId:1331876_1
            queryReceiveOfficialDocumentListReqDto.setOfficialDocumentName(reqDto.getOfficialDocumentName());//SimpleFieldAssign//sourceId:1312815_1
            queryReceiveOfficialDocumentListReqDto.setOfficialDocumentNum(reqDto.getOfficialDocumentNum());//SimpleFieldAssign//sourceId:1312816_1
            queryReceiveOfficialDocumentListReqDto.setReceiveRange(reqDto.getReceiveRange());//SimpleFieldAssign//sourceId:1312817_1
            queryReceiveOfficialDocumentListReqDto.setNotificationType(reqDto.getNotificationType());//SimpleFieldAssign//sourceId:1418260_1
            queryReceiveOfficialDocumentListReqDto.setIsOpenWorkTask(reqDto.getIsOpenWorkTask());//SimpleFieldAssign//sourceId:1312818_1
            queryReceiveOfficialDocumentListReqDto.setWorkTaskIsArrange(reqDto.getWorkTaskIsArrange());//SimpleFieldAssign//sourceId:1312819_1
            queryReceiveOfficialDocumentListReqDto.setCreateTime(reqDto.getCreateTime());//SimpleFieldAssign//sourceId:1312820_1
        }

        /*D3查接收的公文列表[7943]   */

        queryReceiveOfficialDocumentListRespDto = fwAppOfficialDocumentClient.queryReceiveOfficialDocumentList(queryReceiveOfficialDocumentListReqDto).getData()/*vcase invoke 跨dubbo调用;*/;


        queryReceiveOfficialDocumentListRespDto_1 = queryReceiveOfficialDocumentListRespDto;

        BffQueryMyReceiveOfficialDocumentListRespDto retData = new BffQueryMyReceiveOfficialDocumentListRespDto();
        if (queryReceiveOfficialDocumentListRespDto_1 != null) {
            retData.setMyReceiveOfficialDocumentList(queryReceiveOfficialDocumentListRespDto_1.getMyReceiveOfficialDocumentList().stream().map(item -> BeanUtil.toBean(item, BffMyReceiveOfficialDocumentDto.class)).collect(Collectors.toList()));//objList-to-objLists//sourceId:1312828_1
        }


        return retData;
    }

    /**
     * B3修改公文[7927]
     * gen by moon at 12/6/2023, 6:35:17 AM
     */
    @Trace(operationName = "B3修改公文")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffUpdateOfficialDocumentRespDto updateOfficialDocument(BffUpdateOfficialDocumentReqDto reqDto) {


        //步骤0: D3修改公文 - updateOfficialDocument
        UpdateOfficialDocumentRespDto updateOfficialDocumentRespDto = null;
        UpdateOfficialDocumentReqDto updateOfficialDocumentReqDto = new UpdateOfficialDocumentReqDto();
        //todo dong 未找到匹配生成策略,请检查生成策略updateOfficialDocumentReqDto.setBusAppDocRelaList(reqDto.getBusAppDocRelaList().getUnstructuredDataId()),数据源项; to( ==>tableName:undefined, fieldEnname:busAppDocRelaList ,uniqueId: 1317430_1 uniqueSourceId:268512_2) from (varName: fieldreqDto.getBusAppDocRelaList().getUnstructuredDataId())
        if (reqDto != null) {
            updateOfficialDocumentReqDto.setOfficialDocumentId(reqDto.getOfficialDocumentId());//SimpleFieldAssign//sourceId:1311591_1
            updateOfficialDocumentReqDto.setOfficialDocumentName(reqDto.getOfficialDocumentName());//SimpleFieldAssign//sourceId:1311592_1
            updateOfficialDocumentReqDto.setOfficialDocumentUnstructuredDataId(reqDto.getOfficialDocumentUnstructuredDataId());//SimpleFieldAssign//sourceId:1317429_1
            updateOfficialDocumentReqDto.setReceiveRange(reqDto.getReceiveRange());//SimpleFieldAssign//sourceId:1385565_1
            updateOfficialDocumentReqDto.setRemindLevel(reqDto.getRemindLevel());//SimpleFieldAssign//sourceId:1311595_1
            updateOfficialDocumentReqDto.setAppointWorkTaskArrangeInductionId(reqDto.getAppointWorkTaskArrangeInductionId());//SimpleFieldAssign//sourceId:1311596_1
            updateOfficialDocumentReqDto.setSubjectLifeCycle(reqDto.getSubjectLifeCycle());//SimpleFieldAssign//sourceId:1311597_1
            updateOfficialDocumentReqDto.setOrgInductionRecordList(reqDto.getOrgInductionRecordList());//list-field-assign//sourceId:1381971_1
        }
        if (reqDto != null && reqDto.getDeptList() != null && !CollectionUtil.isEmpty(reqDto.getDeptList())) {
            updateOfficialDocumentReqDto.setDeptList(reqDto.getDeptList().stream().map(item -> BeanUtil.toBean(item, DeptDto.class)).collect(Collectors.toList()));//objList-to-objLists//sourceId:1328812_1
        }

        /*D3修改公文[7928]   */
        Assert.isNull(updateOfficialDocumentReqDto.getOfficialDocumentId(), "B3修改公文-D3修改公文-公文ID不能为空", false);
        updateOfficialDocumentRespDto = fwAppOfficialDocumentClient.updateOfficialDocument(updateOfficialDocumentReqDto).getData()/*vcase invoke 跨dubbo调用;*/;


        BffUpdateOfficialDocumentRespDto retData = new BffUpdateOfficialDocumentRespDto();


        return retData;
    }

    /**
     * B3查询公文列表[7933]
     * gen by moon at 12/16/2023, 1:51:40 PM
     */
    @Trace(operationName = "B3查询公文列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffQueryOfficialDocumentListRespDto queryOfficialDocumentList(BffQueryOfficialDocumentListReqDto reqDto) {


        QueryOfficialDocumentListRespDto queryOfficialDocumentListRespDto_1 = null;
//步骤0: D3查询公文列表 - queryOfficialDocumentList
        QueryOfficialDocumentListRespDto queryOfficialDocumentListRespDto = null;
        QueryOfficialDocumentListReqDto queryOfficialDocumentListReqDto = new QueryOfficialDocumentListReqDto();
        if (reqDto != null) {
            queryOfficialDocumentListReqDto.setOfficialDocumentName(reqDto.getOfficialDocumentName());//SimpleFieldAssign//sourceId:1312429_1
            queryOfficialDocumentListReqDto.setOfficialDocumentNum(reqDto.getOfficialDocumentNum());//SimpleFieldAssign//sourceId:1312430_1
            queryOfficialDocumentListReqDto.setReceiveRange(reqDto.getReceiveRange());//SimpleFieldAssign//sourceId:1312431_1
            queryOfficialDocumentListReqDto.setNotificationType(reqDto.getNotificationType());//SimpleFieldAssign//sourceId:1418250_1
            queryOfficialDocumentListReqDto.setIsOpenWorkTask(reqDto.getIsOpenWorkTask());//SimpleFieldAssign//sourceId:1312432_1
            queryOfficialDocumentListReqDto.setWorkTaskIsArrange(reqDto.getWorkTaskIsArrange());//SimpleFieldAssign//sourceId:1312433_1
            queryOfficialDocumentListReqDto.setIssueSubjectId(reqDto.getIssueSubjectId());//SimpleFieldAssign//sourceId:1420022_1
            queryOfficialDocumentListReqDto.setIsArchive(reqDto.getIsArchive());//SimpleFieldAssign//sourceId:1381575_1
            queryOfficialDocumentListReqDto.setSubjectLifeCycle(reqDto.getSubjectLifeCycle());//SimpleFieldAssign//sourceId:1312434_1
            queryOfficialDocumentListReqDto.setCreateTime(reqDto.getCreateTime());//SimpleFieldAssign//sourceId:1312435_1
        }

        /*D3查询公文列表[7934]   */
        Assert.isNull(queryOfficialDocumentListReqDto.getNotificationType(), "B3查询公文列表-D3查询公文列表-通知类型不能为空", false);
        queryOfficialDocumentListRespDto = fwAppOfficialDocumentClient.queryOfficialDocumentList(queryOfficialDocumentListReqDto).getData()/*vcase invoke 跨dubbo调用;*/;


        queryOfficialDocumentListRespDto_1 = queryOfficialDocumentListRespDto;

        BffQueryOfficialDocumentListRespDto retData = new BffQueryOfficialDocumentListRespDto();
        if (queryOfficialDocumentListRespDto_1 != null) {
            retData.setOfficialDocumentList(queryOfficialDocumentListRespDto_1.getOfficialDocumentList().stream().map(item -> BeanUtil.toBean(item, BffOfficialDocumentDto.class)).collect(Collectors.toList()));//objList-to-objLists//sourceId:1312444_1
        }


        retData.setPageNum(queryOfficialDocumentListRespDto.getPageNum());
        retData.setPageSize(queryOfficialDocumentListRespDto.getPageSize());
        retData.setTotal(queryOfficialDocumentListRespDto.getTotalNum());
        retData.setIsLastPage((Math.ceil(Double.valueOf(queryOfficialDocumentListRespDto.getTotalNum()) / Double.valueOf(queryOfficialDocumentListRespDto.getPageSize()))) <= retData.getPageNum());


        return retData;
    }

    /**
     * B3新增公文[7924]
     * gen by moon at 6/9/2024, 1:23:34 AM
     */
    @Trace(operationName = "B3新增公文")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffAddOfficialDocumentRespDto addOfficialDocument(BffAddOfficialDocumentReqDto reqDto) {


        AddOfficialDocumentRespDto addOfficialDocumentRespDto_1 = null;
//步骤0: D3新增公文 - addOfficialDocument
        AddOfficialDocumentRespDto addOfficialDocumentRespDto = null;
        AddOfficialDocumentReqDto addOfficialDocumentReqDto = new AddOfficialDocumentReqDto();
        if (reqDto != null) {
            addOfficialDocumentReqDto.setOfficialDocumentName(reqDto.getOfficialDocumentName());//SimpleFieldAssign//sourceId:1311519_1
            addOfficialDocumentReqDto.setOfficialDocumentNum(reqDto.getOfficialDocumentNum());//SimpleFieldAssign//sourceId:1311520_1
            addOfficialDocumentReqDto.setNotificationDescription(reqDto.getNotificationDescription());//SimpleFieldAssign//sourceId:1420038_1
            addOfficialDocumentReqDto.setOfficialDocumentUnstructuredDataId(reqDto.getOfficialDocumentUnstructuredDataId());//SimpleFieldAssign//sourceId:1857227_1
            addOfficialDocumentReqDto.setPostfix(reqDto.getPostfix());//SimpleFieldAssign//sourceId:1856440_1
            addOfficialDocumentReqDto.setFileRelativePathAccess(reqDto.getFileRelativePathAccess());//SimpleFieldAssign//sourceId:1857228_1
            addOfficialDocumentReqDto.setSourceRelationshipId(reqDto.getSourceRelationshipId());//SimpleFieldAssign//sourceId:1856442_1
            addOfficialDocumentReqDto.setRelationshipType(reqDto.getRelationshipType());//SimpleFieldAssign//sourceId:1856443_1
            addOfficialDocumentReqDto.setIsNetworkReference(reqDto.getIsNetworkReference());//SimpleFieldAssign//sourceId:1856444_1
            addOfficialDocumentReqDto.setReceiveRange(reqDto.getReceiveRange());//SimpleFieldAssign//sourceId:1311523_1
            addOfficialDocumentReqDto.setNotificationType(reqDto.getNotificationType());//SimpleFieldAssign//sourceId:1416393_1
            addOfficialDocumentReqDto.setRemindLevel(reqDto.getRemindLevel());//SimpleFieldAssign//sourceId:1311525_1
            addOfficialDocumentReqDto.setIsOpenWorkTask(reqDto.getIsOpenWorkTask());//SimpleFieldAssign//sourceId:1311526_1
            addOfficialDocumentReqDto.setAppointWorkTaskArrangeInductionId(reqDto.getAppointWorkTaskArrangeInductionId());//SimpleFieldAssign//sourceId:1311528_1
            addOfficialDocumentReqDto.setIssueSubjectId(reqDto.getIssueSubjectId());//SimpleFieldAssign//sourceId:1420015_1
            addOfficialDocumentReqDto.setIssueSubjectTypeCode(reqDto.getIssueSubjectTypeCode());//SimpleFieldAssign//sourceId:1420016_1
            addOfficialDocumentReqDto.setSubjectLifeCycle(reqDto.getSubjectLifeCycle());//SimpleFieldAssign//sourceId:1311527_1
            addOfficialDocumentReqDto.setOrgInductionRecordList(reqDto.getOrgInductionRecordList());//list-field-assign//sourceId:1381955_1
        }
        if (reqDto != null && reqDto.getDeptList() != null && !CollectionUtil.isEmpty(reqDto.getDeptList())) {
            addOfficialDocumentReqDto.setDeptList(reqDto.getDeptList().stream().map(item -> BeanUtil.toBean(item, DeptDto.class)).collect(Collectors.toList()));//objList-to-objLists//sourceId:1328778_1
        }
        if (reqDto != null && reqDto.getAnnexList() != null && !CollectionUtil.isEmpty(reqDto.getAnnexList())) {
            addOfficialDocumentReqDto.setDocumentList(reqDto.getAnnexList().stream().map(item -> BeanUtil.toBean(item, DocumentDto.class)).collect(Collectors.toList()));//objList-to-objLists//sourceId:1313464_1
        }

        /*D3新增公文[7921]   */
        Assert.isNull(addOfficialDocumentReqDto.getOfficialDocumentName(), "B3新增公文-D3新增公文-公文名称不能为空", false);
        Assert.isNull(addOfficialDocumentReqDto.getReceiveRange(), "B3新增公文-D3新增公文-接收范围不能为空", false);
        Assert.isNull(addOfficialDocumentReqDto.getNotificationType(), "B3新增公文-D3新增公文-通知类型不能为空", false);
        Assert.isNull(addOfficialDocumentReqDto.getIsOpenWorkTask(), "B3新增公文-D3新增公文-是否开启工作任务不能为空", false);
        Assert.isNull(addOfficialDocumentReqDto.getSubjectLifeCycle(), "B3新增公文-D3新增公文-主体生命周期不能为空", false);
        addOfficialDocumentRespDto = fwAppOfficialDocumentClient.addOfficialDocument(addOfficialDocumentReqDto).getData()/*vcase invoke 跨dubbo调用;*/;


        addOfficialDocumentRespDto_1 = addOfficialDocumentRespDto;

        BffAddOfficialDocumentRespDto retData = new BffAddOfficialDocumentRespDto();
        if (addOfficialDocumentRespDto_1 != null) {
            retData.setOfficialDocumentId(addOfficialDocumentRespDto_1.getOfficialDocumentId());//SimpleFieldAssign//sourceId:1311573_1
        }


        return retData;
    }

    /**
     * B3查询公文详情[7931]
     * gen by moon at 5/29/2024, 12:41:41 PM
     */
    @Trace(operationName = "B3查询公文详情")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffQueryOfficialDocumentDetailRespDto queryOfficialDocumentDetail(BffQueryOfficialDocumentDetailReqDto reqDto) {


        QueryOfficialDocumentDetailRespDto queryOfficialDocumentDetailRespDto_1 = null;
        QueryInductionRecordDetailComBorderRespDto queryInductionRecordDetailComBorderRespDto_1 = null;
        QueryInductionRecordDetailComBorderRespDto queryInductionRecordDetailComBorderRespDto_3 = null;
        QuerySingleMessageRecipientListListComRespDto querySingleMessageRecipientListListComRespDto_1 = null;
        BatchQueryOriginalRoleMemberInductionRecordComRespDto batchQueryOriginalRoleMemberInductionRecordComRespDto_1 = null;
        BatchQueryUserinfoRespDto batchQueryUserinfoRespDto_1 = null;
//virtualUsage D3查询公文详情  56707
        QueryOfficialDocumentDetailRespDto queryOfficialDocumentDetailRespDto = null;
        QueryOfficialDocumentDetailReqDto queryOfficialDocumentDetailReqDto = new QueryOfficialDocumentDetailReqDto();
        if (reqDto != null) {
            queryOfficialDocumentDetailReqDto.setOfficialDocumentId(reqDto.getOfficialDocumentId());//SimpleFieldAssign//sourceId:1313109_1_56707
        }

        /*D3查询公文详情[7932]   */
        Assert.isNull(queryOfficialDocumentDetailReqDto.getOfficialDocumentId(), "B3查询公文详情-D3查询公文详情-公文ID不能为空", false);
        queryOfficialDocumentDetailRespDto = fwAppOfficialDocumentClient.queryOfficialDocumentDetail(queryOfficialDocumentDetailReqDto).getData()/*vcase invoke 跨dubbo调用;*/;


        queryOfficialDocumentDetailRespDto_1 = queryOfficialDocumentDetailRespDto;
//virtualUsage D1查公文创建人就职记录详情  56710
        QueryInductionRecordDetailComBorderRespDto queryInductionRecordDetailComBorderRespDto = null;
        if (queryOfficialDocumentDetailRespDto != null) {
            QueryInductionRecordDetailComBorderReqDto queryInductionRecordDetailComBorderReqDto = new QueryInductionRecordDetailComBorderReqDto();
            queryInductionRecordDetailComBorderReqDto.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID//sourceId:1313592_1_56710
            if (queryOfficialDocumentDetailRespDto != null) {
                queryInductionRecordDetailComBorderReqDto.setInductionRecordId(queryOfficialDocumentDetailRespDto.getCreateInductionId());//SimpleFieldAssign//sourceId:1313593_1_56710
            }

            /*D1查公文创建人就职记录详情[1340]   */
            Assert.isNull(queryInductionRecordDetailComBorderReqDto.getInductionRecordId(), "B3查询公文详情-D1查公文创建人就职记录详情-就职记录ID不能为空", false);
            Assert.isNull(queryInductionRecordDetailComBorderReqDto.getSpaceId(), "B3查询公文详情-D1查公文创建人就职记录详情-创建于空间ID不能为空", false);
            queryInductionRecordDetailComBorderRespDto = fwBaseInductionRecordClient.queryInductionRecordDetailComBorder(queryInductionRecordDetailComBorderReqDto).getData()/*vcase invoke 跨dubbo调用;*/;


            queryInductionRecordDetailComBorderRespDto_1 = queryInductionRecordDetailComBorderRespDto;
        }
        if ((queryOfficialDocumentDetailRespDto != null && queryOfficialDocumentDetailRespDto.getAppointWorkTaskArrangeInductionId() != null)) {
            //if(D3查询公文详情.指定工作任务安排人就职记录ID 值不等于空 )  56708

            QueryInductionRecordDetailComBorderRespDto queryInductionRecordDetailComBorderRespDto_2 = null;
            if (queryOfficialDocumentDetailRespDto != null) {
                QueryInductionRecordDetailComBorderReqDto queryInductionRecordDetailComBorderReqDto_1 = new QueryInductionRecordDetailComBorderReqDto();
                queryInductionRecordDetailComBorderReqDto_1.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID//sourceId:1313572_1_56709
                if (queryOfficialDocumentDetailRespDto != null) {
                    queryInductionRecordDetailComBorderReqDto_1.setInductionRecordId(queryOfficialDocumentDetailRespDto.getAppointWorkTaskArrangeInductionId());//SimpleFieldAssign//sourceId:1313573_1_56709
                }

                /*D1查工作任务指定安排人就职记录[1340]   */
                Assert.isNull(queryInductionRecordDetailComBorderReqDto_1.getInductionRecordId(), "B3查询公文详情-D1查工作任务指定安排人就职记录-就职记录ID不能为空", false);
                Assert.isNull(queryInductionRecordDetailComBorderReqDto_1.getSpaceId(), "B3查询公文详情-D1查工作任务指定安排人就职记录-创建于空间ID不能为空", false);
                queryInductionRecordDetailComBorderRespDto_2 = fwBaseInductionRecordClient.queryInductionRecordDetailComBorder(queryInductionRecordDetailComBorderReqDto_1).getData()/*vcase invoke 跨dubbo调用;*/;


                queryInductionRecordDetailComBorderRespDto_3 = queryInductionRecordDetailComBorderRespDto_2;
            }
        }
//virtualUsage D2查询该公文接收人列表(公共)  56714
        QuerySingleMessageRecipientListListComRespDto querySingleMessageRecipientListListComRespDto = null;
        if (queryOfficialDocumentDetailRespDto != null) {
            QuerySingleMessageRecipientListListComReqDto querySingleMessageRecipientListListComReqDto = new QuerySingleMessageRecipientListListComReqDto();
            querySingleMessageRecipientListListComReqDto.setBehaviorTypeCode("ISSUE_OFFCIAL_DOC");//CUSTOM_CONVENTION//sourceId:1414926_1_56714
            if (queryOfficialDocumentDetailRespDto != null) {
                querySingleMessageRecipientListListComReqDto.setEntityId(queryOfficialDocumentDetailRespDto.getOfficialDocumentId());//SimpleFieldAssign//sourceId:1414925_1_56714
            }

            /*D2查询该公文接收人列表(公共)[8150]   */
            Assert.isNull(querySingleMessageRecipientListListComReqDto.getEntityId(), "B3查询公文详情-D2查询该公文接收人列表(公共)-归属内容ID不能为空", false);
            Assert.isNull(querySingleMessageRecipientListListComReqDto.getBehaviorTypeCode(), "B3查询公文详情-D2查询该公文接收人列表(公共)-行为类型编码不能为空", false);
            querySingleMessageRecipientListListComRespDto = fwCompMessageClient.querySingleMessageRecipientListListCom(querySingleMessageRecipientListListComReqDto).getData()/*vcase invoke 跨dubbo调用;*/;


            querySingleMessageRecipientListListComRespDto_1 = querySingleMessageRecipientListListComRespDto;
        }
        if ((querySingleMessageRecipientListListComRespDto != null && querySingleMessageRecipientListListComRespDto.getMemberMsgReceiveList() != null && querySingleMessageRecipientListListComRespDto.getMemberMsgReceiveList().size() > 0)) {
            //if(D2查询该公文接收人列表(公共).成员消息接收列表数据集条数 大于 0)  56715

            BatchQueryOriginalRoleMemberInductionRecordComRespDto batchQueryOriginalRoleMemberInductionRecordComRespDto = null;
            if (querySingleMessageRecipientListListComRespDto != null) {
                BatchQueryOriginalRoleMemberInductionRecordComReqDto batchQueryOriginalRoleMemberInductionRecordComReqDto = new BatchQueryOriginalRoleMemberInductionRecordComReqDto();
                batchQueryOriginalRoleMemberInductionRecordComReqDto.setIsMainInduction("TRUE");//sourceId:1414929_1_56716
                batchQueryOriginalRoleMemberInductionRecordComReqDto.setSubjectLifeCycle("CURRENTLY_VALID");//sourceId:1414930_1_56716
                if (querySingleMessageRecipientListListComRespDto != null && querySingleMessageRecipientListListComRespDto.getMemberMsgReceiveList() != null && !CollectionUtil.isEmpty(querySingleMessageRecipientListListComRespDto.getMemberMsgReceiveList())) {
                    batchQueryOriginalRoleMemberInductionRecordComReqDto.setOrgInductionRecordList(querySingleMessageRecipientListListComRespDto.getMemberMsgReceiveList().stream().map(item -> item.getOriginalRoleMemberId())
                            .collect(Collectors.toList()));/*list-to-strings*///sourceId:1414928_1_56716
                }

                /*D1-3批量查接收人就职记录(公共)[5080]   */
                Assert.isNull(batchQueryOriginalRoleMemberInductionRecordComReqDto.getIsMainInduction(), "B3查询公文详情-D1-3批量查接收人就职记录(公共)-是否主岗不能为空", false);
                Assert.isNull(batchQueryOriginalRoleMemberInductionRecordComReqDto.getSubjectLifeCycle(), "B3查询公文详情-D1-3批量查接收人就职记录(公共)-主体生命周期不能为空", false);
                batchQueryOriginalRoleMemberInductionRecordComRespDto = fwBaseInductionRecordClient.batchQueryOriginalRoleMemberInductionRecordCom(batchQueryOriginalRoleMemberInductionRecordComReqDto).getData()/*vcase invoke 跨dubbo调用;*/;


                batchQueryOriginalRoleMemberInductionRecordComRespDto_1 = batchQueryOriginalRoleMemberInductionRecordComRespDto;
            }
            BatchQueryUserinfoRespDto batchQueryUserinfoRespDto = null;
            if (querySingleMessageRecipientListListComRespDto != null) {
                BatchQueryUserinfoReqDto batchQueryUserinfoReqDto = new BatchQueryUserinfoReqDto();
                if (querySingleMessageRecipientListListComRespDto != null && querySingleMessageRecipientListListComRespDto.getMemberMsgReceiveList() != null && !CollectionUtil.isEmpty(querySingleMessageRecipientListListComRespDto.getMemberMsgReceiveList())) {
                    batchQueryUserinfoReqDto.setUserinfoList(querySingleMessageRecipientListListComRespDto.getMemberMsgReceiveList().stream().map(item -> item.getUserId())
                            .collect(Collectors.toList()));/*list-to-strings*///sourceId:1419940_1_56717
                }

                /*D1批量查接收人姓名[1020]   */

                batchQueryUserinfoRespDto = fwBaseNullClient.batchQueryUserinfo(batchQueryUserinfoReqDto).getData()/*vcase invoke 跨dubbo调用;*/;


                batchQueryUserinfoRespDto_1 = batchQueryUserinfoRespDto;
            }
        }
        BffQueryOfficialDocumentDetailRespDto retData = new BffQueryOfficialDocumentDetailRespDto();
        //数据集融合  MoreListToOneSource
        if (querySingleMessageRecipientListListComRespDto_1 != null && !CollectionUtil.isEmpty(querySingleMessageRecipientListListComRespDto_1.getMemberMsgReceiveList())) {
            for (MemberMsgReceiveDto memberMsgReceiveDto : querySingleMessageRecipientListListComRespDto_1.getMemberMsgReceiveList()) {
                BffMemberMsgReceiveDto retElm = new BffMemberMsgReceiveDto();
                if (querySingleMessageRecipientListListComRespDto_1 != null) {
                    retElm.setOriginalRoleMemberId(memberMsgReceiveDto.getOriginalRoleMemberId());//SimpleFieldAssign//sourceId:283890_2
                }
                retData.getMemberMsgReceiveList().add(retElm);
                if (batchQueryOriginalRoleMemberInductionRecordComRespDto_1 != null) {
                    for (OrgInductionRecordDto orgInductionRecordDto : batchQueryOriginalRoleMemberInductionRecordComRespDto_1.getOrgInductionRecordList()) {
                        if (orgInductionRecordDto.getOriginalRoleMemberId().equals(memberMsgReceiveDto.getOriginalRoleMemberId())) {
                            if (batchQueryOriginalRoleMemberInductionRecordComRespDto_1 != null) {
                                retElm.setUserId(orgInductionRecordDto.getUserId());//SimpleFieldAssign//sourceId:283889_2
                                retElm.setDeptShortName(orgInductionRecordDto.getDeptShortName());//SimpleFieldAssign//sourceId:283891_2
                                retElm.setPositionIdName(orgInductionRecordDto.getPositionIdName());//SimpleFieldAssign//sourceId:283892_2
                            }
                        }
                    }
                }

                if (batchQueryUserinfoRespDto_1 != null) {
                    for (UserInfoDto userInfoDto : batchQueryUserinfoRespDto_1.getUserInfoList()) {
                        if (userInfoDto.getUserId().equals(memberMsgReceiveDto.getUserId())) {
                            if (batchQueryUserinfoRespDto_1 != null) {
                                retElm.setIdCardName(userInfoDto.getIdCardName());//SimpleFieldAssign//sourceId:284798_2
                            }
                        }
                    }
                }

            }
        }//sourceId:1414932_1
        if (queryOfficialDocumentDetailRespDto_1 != null) {
            retData.setOfficialDocumentId(queryOfficialDocumentDetailRespDto_1.getOfficialDocumentId());//SimpleFieldAssign//sourceId:1313110_1
            retData.setOfficialDocumentNum(queryOfficialDocumentDetailRespDto_1.getOfficialDocumentNum());//SimpleFieldAssign//sourceId:1313112_1
            retData.setOfficialDocumentName(queryOfficialDocumentDetailRespDto_1.getOfficialDocumentName());//SimpleFieldAssign//sourceId:1313111_1
            retData.setNotificationDescription(queryOfficialDocumentDetailRespDto_1.getNotificationDescription());//SimpleFieldAssign//sourceId:1420046_1
            retData.setReceiveRange(queryOfficialDocumentDetailRespDto_1.getReceiveRange());//SimpleFieldAssign//sourceId:1313113_1
            retData.setOfficialDocumentFileAddressAllPath(queryOfficialDocumentDetailRespDto_1.getOfficialDocumentFileAddress());//SimpleFieldAssign//sourceId:1313114_1
            retData.setUnstructuredDataId(queryOfficialDocumentDetailRespDto_1.getUnstructuredDataId());//SimpleFieldAssign//sourceId:1313556_1
            retData.setUnstructuredDataName(queryOfficialDocumentDetailRespDto_1.getUnstructuredDataName());//SimpleFieldAssign//sourceId:1313557_1
            retData.setFileSize(queryOfficialDocumentDetailRespDto_1.getFileSize());//SimpleFieldAssign//sourceId:1313558_1
            retData.setPostfix(queryOfficialDocumentDetailRespDto_1.getPostfix());//SimpleFieldAssign//sourceId:1313559_1
            retData.setNotificationType(queryOfficialDocumentDetailRespDto_1.getNotificationType());//SimpleFieldAssign//sourceId:1418246_1
            retData.setRemindLevel(queryOfficialDocumentDetailRespDto_1.getRemindLevel());//SimpleFieldAssign//sourceId:1313117_1
            retData.setIsOpenWorkTask(queryOfficialDocumentDetailRespDto_1.getIsOpenWorkTask());//SimpleFieldAssign//sourceId:1313118_1
            retData.setWorkTaskIsArrange(queryOfficialDocumentDetailRespDto_1.getWorkTaskIsArrange());//SimpleFieldAssign//sourceId:1313119_1
            retData.setArrangeWorkTaskId(queryOfficialDocumentDetailRespDto_1.getArrangeWorkTaskId());//SimpleFieldAssign//sourceId:1419950_1
            retData.setArrangeWorkTaskTypeCode(queryOfficialDocumentDetailRespDto_1.getArrangeWorkTaskTypeCode());//SimpleFieldAssign//sourceId:1419951_1
            retData.setAppointWorkTaskArrangeInductionId(queryOfficialDocumentDetailRespDto_1.getAppointWorkTaskArrangeInductionId());//SimpleFieldAssign//sourceId:1313120_1
            retData.setSubjectLifeCycle(queryOfficialDocumentDetailRespDto_1.getSubjectLifeCycle());//SimpleFieldAssign//sourceId:1313121_1
            retData.setCreateInductionId(queryOfficialDocumentDetailRespDto_1.getCreateInductionId());//SimpleFieldAssign//sourceId:1313622_1
            retData.setCreateTime(queryOfficialDocumentDetailRespDto_1.getCreateTime());//SimpleFieldAssign//sourceId:1313623_1
            retData.setAnnexList(queryOfficialDocumentDetailRespDto_1.getAnnexList().stream().map(item -> BeanUtil.toBean(item, BffAnnexDto.class)).collect(Collectors.toList()));//objList-to-objLists//sourceId:1313124_1
        }
        if (queryInductionRecordDetailComBorderRespDto_3 != null) {
            retData.setAppointWorkTaskArrangeOriginalRoleMemberId(queryInductionRecordDetailComBorderRespDto_3.getOriginalRoleMemberId());//SimpleFieldAssign//sourceId:1313606_1
            retData.setAppointWorkTaskArrangeUserId(queryInductionRecordDetailComBorderRespDto_3.getUserId());//SimpleFieldAssign//sourceId:1313607_1
            retData.setAppointWorkTaskArrangeUserFace(queryInductionRecordDetailComBorderRespDto_3.getUserFace());//SimpleFieldAssign//sourceId:1313608_1
            retData.setAppointWorkTaskArrangeIdCardName(queryInductionRecordDetailComBorderRespDto_3.getIdCardName());//SimpleFieldAssign//sourceId:1313609_1
            retData.setAppointWorkTaskArrangeNickName(queryInductionRecordDetailComBorderRespDto_3.getNickName());//SimpleFieldAssign//sourceId:1313610_1
        }
        if (queryInductionRecordDetailComBorderRespDto_1 != null) {
            retData.setCreateOriginalRoleMemberId(queryInductionRecordDetailComBorderRespDto_1.getOriginalRoleMemberId());//SimpleFieldAssign//sourceId:1313624_1
            retData.setCreateUserId(queryInductionRecordDetailComBorderRespDto_1.getUserId());//SimpleFieldAssign//sourceId:1313625_1
            retData.setCreateUserFace(queryInductionRecordDetailComBorderRespDto_1.getUserFace());//SimpleFieldAssign//sourceId:1313626_1
            retData.setCreateIdCardName(queryInductionRecordDetailComBorderRespDto_1.getIdCardName());//SimpleFieldAssign//sourceId:1313627_1
            retData.setCreateNickName(queryInductionRecordDetailComBorderRespDto_1.getNickName());//SimpleFieldAssign//sourceId:1313628_1
        }


        return retData;
    }

    /**
     * B3删除公文[7938]
     * gen by moon at 11/17/2023, 12:49:35 PM
     */
    @Trace(operationName = "B3删除公文")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffDeleteOfficialDocumentRespDto deleteOfficialDocument(BffDeleteOfficialDocumentReqDto reqDto) {


        //步骤0: D3删除公文 - deleteOfficialDocument
        DeleteOfficialDocumentRespDto deleteOfficialDocumentRespDto = null;
        DeleteOfficialDocumentReqDto deleteOfficialDocumentReqDto = new DeleteOfficialDocumentReqDto();
        if (reqDto != null) {
            deleteOfficialDocumentReqDto.setOfficialDocumentId(reqDto.getOfficialDocumentId());//SimpleFieldAssign//sourceId:1312499_1
        }

        /*D3删除公文[7941]   */
        Assert.isNull(deleteOfficialDocumentReqDto.getOfficialDocumentId(), "B3删除公文-D3删除公文-公文ID不能为空", false);
        deleteOfficialDocumentRespDto = fwAppOfficialDocumentClient.deleteOfficialDocument(deleteOfficialDocumentReqDto).getData()/*vcase invoke 跨dubbo调用;*/;


        BffDeleteOfficialDocumentRespDto retData = new BffDeleteOfficialDocumentRespDto();


        return retData;
    }

    /**
     * B3查询未安排的公文列表[8064]
     * gen by moon at 12/15/2023, 2:49:00 PM
     */
    @Trace(operationName = "B3查询未安排的公文列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffQueryUnscheduledOfficialDocListRespDto queryUnscheduledOfficialDocList(BffQueryUnscheduledOfficialDocListReqDto reqDto) {


        QueryUnscheduledOfficialDocListRespDto queryUnscheduledOfficialDocListRespDto_1 = null;
//步骤0: D3查询未安排的公文列表 - queryUnscheduledOfficialDocList
        QueryUnscheduledOfficialDocListRespDto queryUnscheduledOfficialDocListRespDto = null;
        QueryUnscheduledOfficialDocListReqDto queryUnscheduledOfficialDocListReqDto = new QueryUnscheduledOfficialDocListReqDto();
        queryUnscheduledOfficialDocListReqDto.setAppointWorkTaskArrangeInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//CURRENT_INDUCTIONID//sourceId:1368873_1
        queryUnscheduledOfficialDocListReqDto.setNotificationType("OFFICIAL_DOCUMENT");//sourceId:1418256_1

        /*D3查询未安排的公文列表[8062]   */
        Assert.isNull(queryUnscheduledOfficialDocListReqDto.getAppointWorkTaskArrangeInductionId(), "B3查询未安排的公文列表-D3查询未安排的公文列表-指定工作任务安排人就职记录ID不能为空", false);
        queryUnscheduledOfficialDocListRespDto = fwAppOfficialDocumentClient.queryUnscheduledOfficialDocList(queryUnscheduledOfficialDocListReqDto).getData()/*vcase invoke 跨dubbo调用;*/;


        queryUnscheduledOfficialDocListRespDto_1 = queryUnscheduledOfficialDocListRespDto;

        BffQueryUnscheduledOfficialDocListRespDto retData = new BffQueryUnscheduledOfficialDocListRespDto();
        if (queryUnscheduledOfficialDocListRespDto_1 != null) {
            retData.setOfficialDocumentList(queryUnscheduledOfficialDocListRespDto_1.getOfficialDocumentList().stream().map(item -> BeanUtil.toBean(item, BffOfficialDocumentDto.class)).collect(Collectors.toList()));//objList-to-objLists//sourceId:1368875_1
        }


        return retData;
    }
    //
}
